package com.dhee.creditcardsystem.util;

import com.dhee.creditcardsystem.model.App;
import com.dhee.creditcardsystem.model.Users;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class DBUtilAppC {

    public static App dml(String sql, Object... args) {
        Connection conn = null;
        PreparedStatement pstmt = null;
        ResultSet rs = null;
        try {
            conn = DBUtil.getConnection();
//            sql = "select * from users where user_Id = ?";
            pstmt = conn.prepareStatement(sql);
            for (int i = 0; i < args.length; i++) {
                pstmt.setObject(i + 1, args[i]);
            }
            rs = pstmt.executeQuery();
            while (rs.next()) {
                App app = new App();
//                private String appcd;
//                private String cstid;
//                private String syokbn;
//                private String mail;
//                private String ber;
//                private String pho;
//                private String ukttme;
//                private String appsts;
//                private String brdcd;
//                private String crdshucd;
//                private String kjnhjn;
//                private String seikj;
//                private String seikn;
//                private String seien;
//                private String meikj;
//                private String meikn;
//                private String meien;
//                private String sex;
//                private String jkysbt;
//                private String tel;
//                private String post;
//                private String knc;
//                private String jskj1;
//                private String jskj2;
//                private String jskn1;
//                private String jskn2;
//
//
//
//                private String spgtorkbn;
//                private String spgkbn;
//                private String csgkbn;
//                private String torkbn;
//                private String driverid;
//                private String kkhcd;
//                private String hgsumk;
//                private String kzkmlflg;
//                private String cammlflg;
//                private String bankcd;
//                private String bchcd;
//
//                // 第二页字段
//                private String ykn;
//                private String actcd;
//                private String actnae;
//                private String actkkndte;
//                private String actkknid;
//                private String actkknnam;
//                private String agtcd;
//                private String hnnhhucd;
//                private String hnnflg = "0";
//                private String hks1;
//                private String hks2;
//                private String hks3;
//                private String hks4;
//                private String hnnkkndte;
//                private String hnnkknid;
//                private String hankknnam;
//                private String gyocd;
//                private String kms;
//                private String kmsdep;
//                private String kmstel;
//                private String kmsjs1;
//                private String kmsjs2;
//                private String nshym;
//                private String nsg;
//                private String kzkkbn;
//                private String kzkflg = "0";
//                private String kzkseikj;
//                private String kakseikn;
//                private String kzkseien;
//                private String kzkmeikj;
//                private String kamekn;
//                private String kzkmeien;
//                private String kzksex;
//                private String kzkgyocd;
//                private String kzkkms;
//                private String kzkkmsdep;
//                private String kzkkmstel;
//                private String kzkhhucd;
//                private String kzkks1;
//                private String kzkks2;
//                private String kzkks3;
//                private String kzkks4;
//                private String kzkkkndte;
//                private String kzkkknid;
//                private String kzkkknnam;
//
//                // 第三页字段
//                private String ysninf;
//                private String skjsskflg;
//                private String sskiritme;
//                private String sskcd;
//                private String sskjrytme;
//                private String apponctme;
//                private String oldcrdcd;
//                private String insertdte = "2025/11/11";
//                private String insertid = "moren";
//                private String updatedte = "2025/11/11";
//                private String updateid = "moren";
//                private String deleteflg = "0";
//                private String deletedte;
                app.setAppcd(rs.getString("APPCD"));
                app.setCstid(rs.getString("CSTID"));
                app.setSyokbn(rs.getString("SYOKBN"));
                app.setMail(rs.getString("MAIL"));
                app.setBer(rs.getString("BER"));
                app.setPho(rs.getString("PHO"));
                app.setUkttme(rs.getString("UKTTME"));
                app.setAppsts(rs.getString("APPSTS"));
                app.setBrdcd(rs.getString("BRDCD"));
                app.setCrdshucd(rs.getString("CRDSHUCD"));
                app.setKjnhjn(rs.getString("KJNHJN"));
                app.setSeikj(rs.getString("SEIKJ"));
                app.setSeikn(rs.getString("SEIKN"));
                app.setSeien(rs.getString("SEIEN"));
                app.setMeikj(rs.getString("MEIKJ"));
                app.setMeikn(rs.getString("MEIKN"));
                app.setMeien(rs.getString("MEIEN"));
                app.setSex(rs.getString("SEX"));
                app.setJkysbt(rs.getString("JKYSBT"));
                app.setTel(rs.getString("TEL"));
                app.setPost(rs.getString("POST"));
                app.setKnc(rs.getString("KNC"));
                app.setJskj1(rs.getString("JSKJ1"));
                app.setJskj2(rs.getString("JSKJ2"));
                app.setJskn1(rs.getString("JSKN1"));
                app.setJskn2(rs.getString("JSKN2"));
                app.setSpgtorkbn(rs.getString("SPGTORKBN"));
                app.setSpgkbn(rs.getString("SPGKBN"));
                app.setCsgkbn(rs.getString("CSGKBN"));
                app.setTorkbn(rs.getString("TORKBN"));
                app.setDriverid(rs.getString("DRIVERID"));
                app.setKkhcd(rs.getString("KKHCD"));
                app.setHgsumk(rs.getString("HGSUMK"));
                app.setKzkmlflg(rs.getString("KZKMLFLG"));
                app.setCammlflg(rs.getString("CAMMLFLG"));
                app.setBankcd(rs.getString("BANKCD"));
                app.setBchcd(rs.getString("BCHCD"));
                app.setYkn(rs.getString("YKN"));
                app.setActcd(rs.getString("ACTCD"));
                app.setActnae(rs.getString("ACTNAE"));
                app.setActkkndte(rs.getString("ACTKKNDTE"));
                app.setActkknid(rs.getString("ACTKKNID"));
                app.setActkknnam(rs.getString("ACTKKNNAM"));
                app.setAgtcd(rs.getString("AGTCD"));
                app.setHnnhhucd(rs.getString("HNNHHUCD"));
                app.setHnnflg(rs.getString("HNNFLG"));
                app.setHks1(rs.getString("HKS1"));
                app.setHks2(rs.getString("HKS2"));
                app.setHks3(rs.getString("HKS3"));
                app.setHnnkkndte(rs.getString("HNNKKNDTE"));
                app.setHnnkknid(rs.getString("HNNKKNID"));
                app.setHnnkknnam(rs.getString("HNNKKNNAM"));
                app.setGyocd(rs.getString("GYOCD"));
                app.setKms(rs.getString("KMS"));
                app.setKmsdep(rs.getString("KMSDEP"));
                app.setKmstel(rs.getString("KMSTEL"));
                app.setKmsjs1(rs.getString("KMSJS1"));
                app.setKmsjs2(rs.getString("KMSJS2"));
                app.setNshym(rs.getString("NSHYM"));
                app.setNsg(rs.getString("NSG"));
                app.setKzkkbn(rs.getString("KZKKBN"));
                app.setKzkflg(rs.getString("KZKFLG"));
                app.setKzkseikj(rs.getString("KZKSEIKJ"));
                app.setKzkseikn(rs.getString("KZKSEIKN"));
                app.setKzkseien(rs.getString("KZKSEIEN"));
                app.setKzkmeikj(rs.getString("KZKMEIKJ"));
                app.setKzkmeikn(rs.getString("KZKMEIKN"));
                app.setKzkmeien(rs.getString("KZKMEIEN"));
                app.setKzksex(rs.getString("KZKSEX"));
                app.setKzkgyocd(rs.getString("KZKGYOCD"));
                app.setKzkkms(rs.getString("KZKKMS"));
                app.setKzkkmsdep(rs.getString("KZKKMSDEP"));
                app.setKzkkmstel(rs.getString("KZKKMSTEL"));
                app.setKzkhhucd(rs.getString("KZKHHUCD"));
                app.setKzkks1(rs.getString("KZKKS1"));
                app.setKzkks2(rs.getString("KZKKS2"));
                app.setKzkks3(rs.getString("KZKKS3"));
                app.setKzkks4(rs.getString("KZKKS4"));
                app.setKzkkknnam(rs.getString("KZKKKNNAM"));
                app.setYsninf(rs.getString("YSNINF"));
                app.setSkjsskflg(rs.getString("SKJSSKFLG"));
                app.setSskiritme(rs.getString("SSKIRITME"));
                app.setSskcd(rs.getString("SSKCD"));
                app.setSskjrytme(rs.getString("SSKJRYTME"));
                app.setApponctme(rs.getString("APPONCTME"));
                app.setOldcrdcd(rs.getString("OLDCRDCD"));
                app.setInsertdte(rs.getString("INSERTDTE"));
                app.setInsertid(rs.getString("INSERTID"));
                app.setUpdatedte(rs.getString("UPDATEDTE"));
                app.setUpdateid(rs.getString("UPDATEID"));
                app.setDeleteflg(rs.getString("DELETEFLG"));
                app.setDeletedte(rs.getString("DELETEDTE"));

                // 在现有代码基础上添加缺失的字段映射
//                app.setHks4(rs.getString("HKS4"));
//                app.setKzkkmsdep(rs.getString("KZKKMSDEP"));
                return app;
            }

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            DBUtil.close(conn, pstmt, rs);
        }

        return null;
    }
}
